unit certificacion;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, planTiempos, Provider, SqlExpr, FMTBcd, DB, DBClient, DBLocal,
  DBLocalS, Grids, ExtCtrls, StdCtrls, Buttons, DBCtrls, Menus;

type
  TfrmCertificacion = class(TfrmPlanTiempos)
    Splitter2: TSplitter;
    DBMemo1: TDBMemo;
    cdsComentario: TSQLClientDataSet;
    cdsComentarioID_OBRA: TFloatField;
    cdsComentarioFECHA: TSQLTimeStampField;
    cdsComentarioCOMENTARIO: TMemoField;
    sComentario: TDataSource;
    pop: TPopupMenu;
    Evaluaraestafecha1: TMenuItem;
    procedure rbActualizadoClick(Sender: TObject);
    procedure grdItemSelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    procedure cdsComentarioBeforeClose(DataSet: TDataSet);
    procedure cdsComentarioNewRecord(DataSet: TDataSet);
    procedure DBMemo1KeyPress(Sender: TObject; var Key: Char);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure grdPlanSelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    procedure Evaluaraestafecha1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmCertificacion: TfrmCertificacion;

implementation

uses Recursos, MDatos, evaluaAvance;

{$R *.dfm}

procedure TfrmCertificacion.rbActualizadoClick(Sender: TObject);
var
  i: byte;
begin
  for i:= 1 to self.grdPlan.RowCount -1 do
    self.grdPlan.Rows[i].Clear;
  self.cargarGrilla;
end;

procedure TfrmCertificacion.grdItemSelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
var
  fecha: string;
  grilla: TStringGrid;
begin
  //inherited;
  try
    grilla := TStringGrid(Sender);
    fecha := FormatDateTime('mm/dd/yy', StrToDate(grilla.Cells[ACol, 0]));
    self.cdsComentario.Close;
    self.cdsComentario.Params [0].AsString := self.idPre;
    self.cdsComentario.Params [1].AsString := fecha;
    self.cdsComentario.Open;
  except
    self.cdsComentario.Close;
  end;
end;

procedure TfrmCertificacion.cdsComentarioBeforeClose(DataSet: TDataSet);
begin
  if (self.cdsComentario.State in [dsEdit, dsInsert]) then
  begin
    self.cdsComentario.Post;
    self.cdsComentario.ApplyUpdates(0);
  end;
end;

procedure TfrmCertificacion.cdsComentarioNewRecord(DataSet: TDataSet);
begin
  self.cdsComentarioID_OBRA.AsString := self.idPre;
  self.cdsComentarioFECHA.AsDateTime := self.cdsComentario.Params [1].AsDateTime;
end;

procedure TfrmCertificacion.DBMemo1KeyPress(Sender: TObject;
  var Key: Char);
begin
  Key := upCase(Key);
end;

procedure TfrmCertificacion.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  self.cdsComentarioBeforeClose(self.cdsComentario);
  inherited;  
end;

procedure TfrmCertificacion.grdPlanSelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
  self.grdItemSelectCell(Sender, ACol, ARow, CanSelect);
  inherited;
end;

procedure TfrmCertificacion.Evaluaraestafecha1Click(Sender: TObject);
begin
  TfrmEvaluaAvance.Crear(self, StrToDate(self.grdPlan.Cells[self.grdPlan.col,0]), self.idPre, self.denominacion);
end;

end.
